<template>
  <!-- 搜索框 -->
  <MyFilter
    :partParams="basicParams"
    @get-data="getData"
    @get-table-data="getTableData"
    @open-modal="openModal"
  />
  <!-- 列表 -->
  <MyTable ref="table" :partParams="tableParams" :tableInfo="tableInfo" />
  <!-- 新增弹框 -->
  <AddModal ref="modalRef" :partParams="basicParams" @refresh="refresh" />
</template>

<script lang="ts" setup>
import MyFilter from '../../../common/MyFilter.vue'
import MyTable from '../MyTable.vue'
import AddModal from '../../../common/AddModal.vue'
import { computed, defineProps, ref } from 'vue'
import * as BasicApi from '@/api'
import { useMessage } from '@/hooks/useMessage'

//定义接收的props
const props = defineProps({
  // 定义一个对象类型的 prop
  data: {
    type: Object,
    default: () => ({ groupName: '', jobType: '' })
  }
})

const basicParams = computed(() => {
  return {
    groupName: props.data.groupName,
    jobType: props.data.jobType,
    operType: 'GetList'
  }
})

const tableParams = ref()

const table = ref()
/** 查询列表 */
const getData = async (query: any) => {
  tableParams.value = JSON.parse(JSON.stringify(query))
}

const tableInfo = ref([])
// 获取表格信息
const getTableData = (data: any) => {
  tableInfo.value = data
}

const message = useMessage()
//新增
const modalRef = ref()
const openModal = async () => {
  modalRef.value.open()
}

const refresh = () => {
  tableParams.value = {
    ...basicParams,
    ...tableParams.value
  }
}
</script>
